package 面向对象.课堂练习.编程题;

import java.util.Iterator;
import java.util.TreeSet;

/**
 * @author IT_Jay
 * @date 2022/1/9 10:10 AM
 */
public class TreeSetDeno {
    public static void main(String[] args) {
        TreeSet<Seaweed> seaweedSet = new TreeSet<Seaweed>(new MyComparator());
        Seaweed s1 = new Seaweed();
        Seaweed s2 = new Seaweed();
        Seaweed s3 = new Seaweed();
        Seaweed s4 = new Seaweed();
        s1.setName("A");
        s2.setName("B");
        s3.setName("c");
        s4.setName("D");
        seaweedSet.add(s1);
        seaweedSet.add(s2);
        seaweedSet.add(s3);
        seaweedSet.add(s4);
        Iterator<Seaweed> it = seaweedSet.iterator();
        while(it.hasNext()){
            Seaweed temp = it.next();
            System.out.println(temp.print());
        }

    }
}
